/*
 * 应用入口文件 ylm
 */

(function() {
	'use strict';
	
	//	获取浏览器版本
	function getBrowserVersion(){
	    var userAgent = navigator.userAgent; 
	    var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera,
	    	isChrome = userAgent.indexOf("Chrome") > -1,
	    	isFF = userAgent.indexOf("Firefox") > -1,
	    	isOpera = userAgent.indexOf("Opera") > -1,
	    	isSafari = userAgent.indexOf("Safari") > -1;
    	if(isChrome) {
 	    	return 'Chrome';
 	    }
	    if (isIE) {
	        var IE6 = IE7 = IE8 = false;
	        var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
	        reIE.test(userAgent);
	        var fIEVersion = parseFloat(RegExp["$1"]);
	        IE6 = fIEVersion == 6;
	        IE7 = fIEVersion == 7;
	        IE8 = fIEVersion == 8;
	        if (IE6) {
	            return "IE6";
	        }
	        if (IE7) {
	            return "IE7";
	        }
	        if (IE8) {
	            return "IE8";
	        }
	    }
	    if(isFF) {
	        return "FF";
	    }
	    if(isOpera) {
	        return "Opera";
	    }
	    if(isSafari) {
	    	return "Safari";
	    }
	}
	
	var jqueryPath, bootstrapDeps;
	var bv = getBrowserVersion();
	if(bv == 'IE8' || bv == 'IE7' || bv == 'IE6') {
		jqueryPath = 'component/jquery/jquery-1.11.3.min';
		bootstrapDeps = ['jquery', 'html5shiv', 'respond'];
	} else {
		jqueryPath = 'component/jquery/jquery-1.11.3.min';
		bootstrapDeps = ['jquery', 'html5shiv', 'respond'];
		/*jqueryPath = 'component/jquery/jquery-3.1.0';
		bootstrapDeps = ['jquery'];*/
	}

	//	应用组件相关配置
	require.config({
		baseUrl: 'resources/js',
		paths: {
			jquery: jqueryPath,
			bootstrap: 'component/bootstrap/bootstrap.min',
			html5shiv: 'component/html5/html5shiv-3.7.0.min',
			respond: 'component/html5/respond-1.3.0.min',
			bootstrapTable: 'component/bootstrapTable/bootstrap-table-1.11.1',
			bootstrapTableZh: 'component/bootstrapTable/bootstrap-table-zh-CN',
			select2: 'component/select2/select2.min',
			datetimepicker: 'component/bootstrapDatetimepicker/bootstrap-datetimepicker',
			datetimepickerZh: 'component/bootstrapDatetimepicker/bootstrap-datetimepicker.zh-CN',
			validator: 'component/bootstrapValidator/bootstrapValidator',
			vbox: 'component/orange/validatorBox',
			echartsAll: 'component/echarts/echarts-all',
			orange: 'component/orange/orange',
			navigation: 'component/orange/navigation',
			box: 'component/orange/box',
			form: 'component/orange/form',
			dynamicTable: 'component/orange/dynamicTable',
			fileinput: 'component/bootstrap-fileinput/fileinput.min',
			html2canvas: 'component/html2canvas/html2canvas.min',
			jspdf: 'component/jspdf/jspdf.debug',
			confirm: 'component/jqueryConfirm/jquery-confirm'
		},
		shim: {
			bootstrap: {
				exps: 'bootstrap',
				deps: bootstrapDeps
			},
			bootstrapTable: {
				deps: ['bootstrap']
			},
			bootstrapTableZh: {
				deps: ['bootstrapTable']
			},
			select2: {
				deps: [bootstrapDeps, 'bootstrap']
			},
			datetimepicker: {
				deps: ['bootstrap']
			},
			datetimepickerZh: {
				deps: [bootstrapDeps, 'datetimepicker']
			},
			validator: {
				exps: 'validator',
				deps: bootstrapDeps
			},
			fileinput: {
				exps: 'fileinput',
				deps: [bootstrapDeps, 'bootstrap']
			},
			html2canvas: {
				deps: bootstrapDeps
			},
			jspdf: {
				deps: bootstrapDeps
			},
			confirm: {
				deps: bootstrapDeps
			}
		}
	});
	
	//	加载组件orange并启动应用
	require(['orange'], function(orange) {
		$(function() {
			orange.start();
		});
	});
})();
